import request from '../utils/request';

// 项目验收单管理相关API
export const projectAcceptanceApi = {
  // 根据项目ID查询验收单列表
  getAcceptanceByProject: (projectId) => {
    return request.get(`/api/project-acceptance/project/${projectId}`);
  },

  // 根据验收单ID查询验收单详情
  getAcceptanceById: (id) => {
    return request.get(`/api/project-acceptance/${id}`);
  },

  // 创建验收单
  createAcceptance: (data) => {
    return request.post('/api/project-acceptance', data);
  },

  // 更新验收单
  updateAcceptance: (id, data) => {
    return request.put(`/api/project-acceptance/${id}`, data);
  },

  // 更新验收单状态
  updateAcceptanceStatus: (id, status) => {
    return request.put(`/api/project-acceptance/${id}/status`, null, {
      params: { status }
    });
  },

  // 删除验收单
  deleteAcceptance: (id) => {
    return request.delete(`/api/project-acceptance/${id}`);
  },

  // 提交验收单
  submitAcceptance: (id) => {
    return request.post(`/api/project-acceptance/${id}/submit`);
  },

  // 审核验收单
  reviewAcceptance: (id, status, remark) => {
    return request.post(`/api/project-acceptance/${id}/review`, null, {
      params: { status, remark }
    });
  },

  // 完成验收单
  completeAcceptance: (id) => {
    return request.post(`/api/project-acceptance/${id}/complete`);
  },

  // 更新验收单完成时间
  updateAcceptanceCompletionTime: (id, completionTime) => {
    return request.put(`/api/project-acceptance/${id}/completion-time`, null, {
      params: { completionTime }
    });
  }
};

// 验收成员管理相关API
export const acceptanceMemberApi = {
  // 根据验收单ID查询验收成员列表
  getMembersByAcceptance: (acceptanceId) => {
    return request.get(`/api/acceptance-member/acceptance/${acceptanceId}`);
  },

  // 根据验收成员ID查询详情
  getMemberById: (id) => {
    return request.get(`/api/acceptance-member/${id}`);
  },

  // 创建验收成员
  createMember: (data) => {
    return request.post('/api/acceptance-member', data);
  },

  // 批量创建验收成员
  batchCreateMembers: (data) => {
    return request.post('/api/acceptance-member/batch', data);
  },

  // 更新验收成员
  updateMember: (id, data) => {
    return request.put(`/api/acceptance-member/${id}`, data);
  },

  // 更新验收成员状态
  updateMemberStatus: (id, status) => {
    return request.put(`/api/acceptance-member/${id}/status`, null, {
      params: { status }
    });
  },

  // 删除验收成员
  deleteMember: (id) => {
    return request.delete(`/api/acceptance-member/${id}`);
  },

  // 根据员工ID查询验收记录
  getMembersByEmployee: (employeeId) => {
    return request.get(`/api/acceptance-member/employee/${employeeId}`);
  },

  // 转项成员
  transferMember: (id, data) => {
    return request.put(`/api/acceptance-member/${id}/transfer`, data);
  }
};
